﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SqlToolkit
{
    /// <summary></summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public class TableRowPrimaryKey : Attribute
    {
        public TableRowPrimaryKey() { }

        //add GetAttributes
    }

    /// <summary></summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public class TableRowForeignKey : Attribute
    {
        public TableRowForeignKey(string joinTable, string joinOnColumn)
        {
            _table = joinTable;
            _column = joinOnColumn;
        }
        private string _table = string.Empty;
        public string JoinTable { get { return _table; } }

        private string _column = string.Empty;
        public string JoinOnColumn { get { return _column; } }

        //add GetAttributes
    }

    /// <summary>
    /// Summary description for TableRowFieldAttribute.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public class TableRowFieldAttribute : Attribute
    {
        #region Construction
        /// <summary>
        /// Mark a property or field as the representation of a table field.
        /// </summary>
        /// <param name="name">The name of the field.</param>
        /// <param name="datatype">The datatype of the field.</param>
        /// <param name="length">The max length or numeric precision of the field.</param>
        public TableRowFieldAttribute(string name, string datatype, bool nullable, int length, int oridinal_position)
        {
            _name = name;
            _datatype = datatype;
            _len = length;
            _ord = oridinal_position;
            _null = nullable;
        }
        #endregion
        #region Name
        string _name = string.Empty;
        /// <summary>
        /// The name of the field.
        /// </summary>
        public string FieldName
        {
            get { return _name; }
        }
        #endregion
        private string _datatype = "";
        public string DataType { get { return _datatype; } }

        private int _len = 0;
        public int Length { get { return _len; } }

        private int _ord = 0;
        public int OridinalPosition { get { return _ord; } }

        private bool _null = true;
        public bool Nullable { get { return _null; } }

        //add GetAttributes

    }

    /// <summary>
    /// Used to mark classes/structs as being a represintation of a row of data found in a table.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
    public class TableRowAttribute : Attribute
    {
        #region Construction
        /// <summary>
        /// Create a TableRow mark on an class/struct.
        /// </summary>
        /// <param name="name">The name of the table.</param>
        public TableRowAttribute(string name)
        {
            this.name = name;
        }
        #endregion
        #region Name
        string name = string.Empty;
        /// <summary>
        /// The name of the table.
        /// </summary>
        public string TableName
        {
            get { return name; }
        }
        #endregion

        //add GetAttributes
    }




}
